package com.quarkus.validate;

import lombok.extern.slf4j.Slf4j;

import javax.enterprise.context.ApplicationScoped;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Author: TongRui乀
 * @Date: 2021/2/28 10:52
 * @description：
 */
@ApplicationScoped
@Slf4j
public class StartWithValidator implements ConstraintValidator<StartWith, String> {

    private StartWith startWith;

    @Override
    public boolean isValid(String s, ConstraintValidatorContext context) {
        log.info("自定义参数校验");
        System.out.println(context.getDefaultConstraintMessageTemplate());
        System.out.println(startWith.prefix());
        return false;
    }

    @Override
    public void initialize(StartWith constraintAnnotation) {
        this.startWith  = constraintAnnotation;
    }
}
